/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistence;

import java.util.List;
import model.Klant;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 *
 * @author Matthy & Jelle
 */
public class KlantService extends AbstractService{

  @Override
  public boolean validate(Object o) {
    Klant k = (Klant)o;
    return !(k.getNaam().isEmpty() || k.getNaam() == null || k.getVoornaam().isEmpty() || k.getVoornaam() == null);
  }

  public List<Klant> getKlanten() {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();
    Query query = session.createQuery("from Klant");
    List<Klant> klanten = query.list();
    session.getTransaction().commit();
    return klanten;
  }

}
